<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>支出收入记录</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/layui/layui.js"></script>
    <script type="text/javascript" src="/jquery.min.js"></script>
    <script type="text/javascript" src="/sb/Tips.min.js"></script>
</head>
<body>

<div class="" style="padding:15px;">

    <link rel="stylesheet" href="/goods/order.css"/>
    <form class="layui-form layui-form-pane1">
        <div class="layui-form-item">
            <label class="layui-form-label">业务日期</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" name="createDate" id="createDate" autocomplete="off" lay-verify="required" placeholder="yyyy-MM-dd">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所属店铺</label>
            <div class="layui-input-inline">
                <select name="shopId" id="shopId" lay-verify="required">
                    <option value="">选择店铺</option>
                    <option value="6">淘宝-梦小妮牛仔裤</option>
                    <option value="5">拼多多-梦小妮牛仔裤</option>
                    <option value="22">抖店-梦小妮牛仔裤</option>
                    <!-- <option value="21">小红书-珍姐姐de衣柜的小店</option> -->
                    <!-- <option value="13">快手-珍姐姐de衣柜</option> -->
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">收支类型</label>
            <div class="layui-input-inline">
                <select name="type" id="type" lay-verify="required">
                    <option value="">收支类型</option>
                    <option value="1">支出</option>
                    <option value="2">收入</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">来源/用途</label>
            <div class="layui-input-inline">
                <select name="source" id="source" lay-verify="required">
                    <option value="">来源/用途</option>
                    <option value="PURCHASE">采购支出</option>
                    <option value="SHOPORDER">订单收入</option>
                    <option value="TIXIAN">店铺提现</option>
                    <option value="YINGXIAO">销售费用-广告费</option>
                    <option value="SALEFEE">销售费用-其他</option>
                    <option value="YONGJIN">销售费用-佣金</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">金额</label>
            <div class="layui-input-inline">
                <input type="text" name="amount" lay-verify="required|number" autocomplete="off"
                       placeholder="金额" maxlength="11" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">业务单号</label>
            <div class="layui-input-block">
                <input type="text" name="sourceNo"  autocomplete="off" 
                       placeholder="来源业务单号，采购单号、订单号等" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea placeholder="备注" name="remark" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" lay-filter="orderConfirm" class="layui-btn" lay-submit="" >订单确认</button>
                <i style="color: red" th:text="${error}"></i>
            </div>
        </div>
    </form>


    <!-- end dd-wrapper -->
    <script>
        //JavaScript代码区域
        var layer;
        var $;
        var form;
        var index = 0;
        try {
            index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        }catch (e) {
        }

        layui.use(['laydate', 'jquery', 'form', 'layer'], function () {
            var laydate = layui.laydate;
            form = layui.form;
            layer = layui.layer;
            $ = layui.jquery;
            laydate.render({
                elem: '#createDate'
            });

            //监听提交
            form.on('submit(orderConfirm)', function(data){

                if(confirm("确定添加该笔财务记录吗？")) {
                    $.ajax({
                        url: "/ajax_funds/create",
                        type: "POST",
                        dataType: "JSON",
                        contentType: 'application/json',
                        data: JSON.stringify(data.field),
                        success: function (res) {
                            if (res.code == 0) {
                                alert("添加成功");
                            } else {
                                alert(res.msg);
                            }
                            parent.layer.close(index);
                            parent.location.reload();
                        }
                    })
                }
                // layer.alert(JSON.stringify(data.field), {
                //     title: '最终的提交信息'
                // })
                return false;
            });

        });
    </script>
</div>
</body>
<html>
